package com.xiaocg.combination;

import java.util.ArrayList;
import java.util.List;

/**
 * 菜单项
 */
public class Menu extends MenuComponent{

    private List<MenuComponent> components  = new ArrayList<>();

    public Menu(String name,Integer level) {
        this.name = name;
        this.level = level;
    }

    @Override
    public void add(MenuComponent component) {
        components.add(component);
    }

    @Override
    public void remove(MenuComponent component) {
        components.remove(component);
    }

    @Override
    public MenuComponent get(int index) {
        return components.get(index);
    }

    @Override
    public void print() {
        System.out.println("菜单项:"+name);
        for (MenuComponent m: components) {
            m.print();
        }
    }
}
